{extend name="normal_base" /}
{block name="navigation"}{/block}
{block name="css"}
<style>
</style>
{/block}
{block name="body"}
<div class="x-body">
    <blockquote class="layui-elem-quote" style="color: #AAAAAA">Tip ： 点击：“纳税人识别号” 可以跳转到“国家企业信用信息公示系统”； 星级会自动根据录入的业务额进行评定，点击 “星级” 可以查看规则详情</blockquote>
    <form class="layui-form" id="from_id" method="POST" action="{:url('edit')}" lay-filter="form-id">
        <!--客户编号：-->
        <div class="layui-form-item">
            <label for="customer_number" class="layui-form-label">
                <span class="x-red">*</span>&nbsp;客户编号：
            </label>
            <div class="layui-input-block">
                <input type="text" id="customer_number" lay-verify="required" disabled placeholder="" autocomplete="off" class="layui-input" value="{$customer_info.customer_number}">
            </div>
        </div>

        <!--客户单位名称-->
        <div class="layui-form-item">
            <label for="company_name" class="layui-form-label">
                <span class="x-red">*</span>&nbsp;单位名称：
            </label>
            <div class="layui-input-block">
                <input type="text" id="company_name" name="company_name" required="" lay-verify="required|m_input_long"
                       autocomplete="off" class="layui-input" value="{$customer_info.company_name}">
            </div>
        </div>

        <!--纳税人识别号-->
        <div class="layui-form-item">
            <label for="taxpayer_identity_numbe" class="layui-form-label" id="select-taxpayer_identity_numbe">
                纳税人识别号（<i class="layui-icon layui-icon-search"></i>）：
            </label>
            <div class="layui-input-block">
                <input type="text" id="taxpayer_identity_numbe" name="taxpayer_identity_numbe" lay-verify="m_input_long"
                       autocomplete="off" class="layui-input" value="{$customer_info.taxpayer_identity_numbe}">
            </div>
        </div>

        <!--客户单位简称-->
        <div class="layui-form-item">
            <label for="short_name" class="layui-form-label">
                单位简称：
            </label>
            <div class="layui-input-block">
                <input type="text" id="short_name" name="short_name" required="" lay-verify="m_input_short"
                       autocomplete="off" class="layui-input" value="{$customer_info.short_name}">
            </div>
        </div>

        <!--区域-->
        <div class="layui-form-item" id="x-city">
            <label class="layui-form-label">所在地区：</label>
            <div class="layui-input-inline" style="width: 20%">
                <select name="province_id" lay-filter="region" id="province">
                    <option value=0>请选择省</option>
                </select>
            </div>
            <div class="layui-input-inline" style="width: 20%">
                <select name="city_id" lay-filter="region" id="city">
                    <option value=0>请选择市</option>
                </select>
            </div>
            <div class="layui-input-inline" style="width: 20%">
                <select name="district_id" lay-filter="region" id="district">
                    <option value=0>请选择县/区</option>
                </select>
            </div>
        </div>

        <!--客户所在地址具体信息（办公地址）-->
        <div class="layui-form-item">
            <label for="address" class="layui-form-label">
                具体地址：
            </label>
            <div class="layui-input-block">
                <input type="text" id="address" name="address" lay-verify="m_address|m_input_long"
                       autocomplete="off" class="layui-input" value="{$customer_info.address}">
            </div>
        </div>

        <!--主营业务范围-->
        <div class="layui-form-item">
            <label for="business_scope" class="layui-form-label">
                主营业务范围：
            </label>
            <div class="layui-input-block">
                <input type="text" id="business_scope" name="business_scope" lay-verify="m_input_long"
                       autocomplete="off" class="layui-input" value="{$customer_info.business_scope}">
            </div>
        </div>

        <!--法定代表人-->
        <div class="layui-form-item">
            <label for="legal_person" class="layui-form-label">
                法定代表人：
            </label>
            <div class="layui-input-block">
                <input type="text" id="legal_person" name="legal_person" lay-verify="m_name"
                       autocomplete="off" class="layui-input" value="{$customer_info.legal_person}">
            </div>
        </div>

        <!--业务额-->
        <div class="layui-form-item">
            <label for="revenue" class="layui-form-label">
                业务额（元）：
            </label>
            <div class="layui-input-block">
                <input type="text" id="revenue" name="revenue" lay-verify=""
                       autocomplete="off" class="layui-input" placeholder="￥" value="{$customer_info.revenue}">
            </div>
        </div>

        <!--星级-->
        <div class="layui-form-item">
            <label for="star-level-id" class="layui-form-label">
                <i class="layui-icon layui-icon-help" id="star-level-help">星级：</i>
            </label>
            <div class="layui-input-inline" id="star-level-id"></div>
        </div>

        <!--财务软件-->
        <div class="layui-form-item">
            <label for="financial_software" class="layui-form-label">
                财务软件：
            </label>
            <div class="layui-input-block">
                <select name="financial_software" lay-verify="m_input_long" id="financial_software">
                    <option value="">请选择财务软件</option>
                    {foreach name="software_list" item="vo"}
                    <option value="{$vo.software_name}" {if condition="$vo.software_name == $customer_info.financial_software"} selected="selected"  {/if}>{$vo.software_name}</option>
                    {/foreach}
                </select>
            </div>
        </div>

        <!--税收优惠-->
        <div class="layui-form-item">
            <label for="tax_discount" class="layui-form-label">
                税收优惠：
            </label>
            <div class="layui-input-block">
                <input type="text" id="tax_discount" name="tax_discount" lay-verify="m_input_short"
                       autocomplete="off" class="layui-input" value="{$customer_info.tax_discount}">
            </div>
        </div>

        <!--主管税务机关-->
        <div class="layui-form-item">
            <label for="tax_bureau" class="layui-form-label">
                主管税务机关：
            </label>
            <div class="layui-input-block">
                <input type="text" id="tax_bureau" name="tax_bureau" lay-verify="m_input_long"
                       autocomplete="off" class="layui-input" value="{$customer_info.tax_bureau}">
            </div>
        </div>

        <!--是否是一般纳税人，1：是，0：否-->
        <div class="layui-form-item">
            <label class="layui-form-label">
                是否是一般纳税人：
            </label>
            <div class="layui-input-block">
                <input type="radio" name="is_general_taxpayer" value="1" title="是" {if condition="$customer_info.is_general_taxpayer == 1"} checked="checked" {/if}>
                <input type="radio" name="is_general_taxpayer" value="0" title="否" {if condition="$customer_info.is_general_taxpayer == 0"} checked="checked" {/if}>
            </div>
        </div>

        <!--税务机关专管员-->
        <div class="layui-form-item">
            <label for="tax_bureau_manager" class="layui-form-label">
                税务机关专管员：
            </label>
            <div class="layui-input-block">
                <input type="text" id="tax_bureau_manager" name="tax_bureau_manager" lay-verify="m_name"
                       autocomplete="off" class="layui-input" value="{$customer_info.tax_bureau_manager}">
            </div>
        </div>

        <!--税务机关专管员-->
        <div class="layui-form-item">
            <!--税务机关专管员联系电话-->
            <label for="tax_bureau_manager_tel" class="layui-form-label">
                税务机关专管员联系电话：
            </label>
            <div class="layui-input-block">
                <input type="text" id="tax_bureau_manager_tel" name="tax_bureau_manager_tel" value="{$customer_info.tax_bureau_manager_tel}" lay-verify="m_phone" autocomplete="off" class="layui-input">
            </div>
        </div>

        <!--税务机关专管员qq-->
        <div class="layui-form-item">
            <label for="tax_bureau_manager_qq" class="layui-form-label">
                税务机关专管员QQ：
            </label>
            <div class="layui-input-block">
                <input type="text" id="tax_bureau_manager_qq" name="tax_bureau_manager_qq" lay-verify="m_qq"
                       autocomplete="off" class="layui-input" value="{$customer_info.tax_bureau_manager_qq}">
            </div>
        </div>

        <!--税务机关专管员微信-->
        <div class="layui-form-item">
            <label for="tax_bureau_manager_wx" class="layui-form-label">
                税务机关专管员微信：
            </label>
            <div class="layui-input-block">
                <input type="text" id="tax_bureau_manager_wx" value="{$customer_info.tax_bureau_manager_wx}" name="tax_bureau_manager_wx" lay-verify="m_wx" autocomplete="off" class="layui-input">
            </div>
        </div>

        <!--税务机关专管员邮箱-->
        <div class="layui-form-item">
            <label for="tax_bureau_manager_email" class="layui-form-label">
                税务机关专管员邮箱：
            </label>
            <div class="layui-input-block">
                <input type="text" id="tax_bureau_manager_email" name="tax_bureau_manager_email" lay-verify="m_email"
                       autocomplete="off" class="layui-input" value="{$customer_info.tax_bureau_manager_email}">
            </div>
        </div>

        <!--财务副总-->
        <div class="layui-form-item">
            <label for="financial_deputy_majordomo" class="layui-form-label">
                财务副总：
            </label>
            <div class="layui-input-block">
                <input type="text" id="financial_deputy_majordomo" name="financial_deputy_majordomo" lay-verify="m_name"
                       autocomplete="off" class="layui-input" value="{$customer_info.financial_deputy_majordomo}">
            </div>
        </div>

        <!--财务副总-->
        <div class="layui-form-item">
            <!--财务副总联系电话-->
            <label for="financial_deputy_majordomo_tel" class="layui-form-label">
                财务副总联系电话：
            </label>
            <div class="layui-input-block">
                <input type="text" id="financial_deputy_majordomo_tel" name="financial_deputy_majordomo_tel" lay-verify="m_phone"
                       autocomplete="off" class="layui-input" value="{$customer_info.financial_deputy_majordomo_tel}">
            </div>
        </div>

        <!--财务副总联系qq-->
        <div class="layui-form-item">
            <label for="financial_deputy_majordomo_qq" class="layui-form-label">
                财务副总QQ：
            </label>
            <div class="layui-input-block">
                <input type="text" id="financial_deputy_majordomo_qq" name="financial_deputy_majordomo_qq" lay-verify="m_qq"
                       autocomplete="off" class="layui-input" value="{$customer_info.financial_deputy_majordomo_qq}">
            </div>
        </div>

        <!--财务副总微信-->
        <div class="layui-form-item">
            <label for="financial_deputy_majordomo_wx" class="layui-form-label">
                财务副总微信：
            </label>
            <div class="layui-input-block">
                <input type="text" id="financial_deputy_majordomo_wx" name="financial_deputy_majordomo_wx" lay-verify="m_wx"
                       autocomplete="off" class="layui-input" value="{$customer_info.financial_deputy_majordomo_wx}">
            </div>
        </div>

        <!--财务副总邮箱-->
        <div class="layui-form-item">
            <label for="financial_deputy_majordomo_email" class="layui-form-label">
                财务副总邮箱：
            </label>
            <div class="layui-input-block">
                <input type="text" id="financial_deputy_majordomo_email" name="financial_deputy_majordomo_email" lay-verify="m_email"
                       autocomplete="off" class="layui-input" value="{$customer_info.financial_deputy_majordomo_email}">
            </div>
        </div>

        <!--财务经理-->
        <div class="layui-form-item">
            <label for="financial_deputy_manager" class="layui-form-label">
                财务经理：
            </label>
            <div class="layui-input-block">
                <input type="text" id="financial_deputy_manager" name="financial_deputy_manager" lay-verify="m_name"
                       autocomplete="off" class="layui-input" value="{$customer_info.financial_deputy_manager}">
            </div>
        </div>

        <!--财务经理联系电话-->
        <div class="layui-form-item"><label for="financial_deputy_manager_tel" class="layui-form-label">
            财务经理联系电话：
        </label>
            <div class="layui-input-block">
                <input type="text" id="financial_deputy_manager_tel" name="financial_deputy_manager_tel" lay-verify="m_phone"
                       autocomplete="off" class="layui-input" value="{$customer_info.financial_deputy_manager_tel}">
            </div>
        </div>

        <!--财务经理qq-->
        <div class="layui-form-item">
            <label for="financial_deputy_manager_qq" class="layui-form-label">
                财务经理QQ：
            </label>
            <div class="layui-input-block">
                <input type="text" id="financial_deputy_manager_qq" name="financial_deputy_manager_qq" lay-verify="m_qq"
                       autocomplete="off" class="layui-input" value="{$customer_info.financial_deputy_manager_qq}">
            </div>
        </div>

        <!--财务经理微信-->
        <div class="layui-form-item"><label for="financial_deputy_manager_wx" class="layui-form-label">
            财务经理微信：
        </label>
            <div class="layui-input-block">
                <input type="text" id="financial_deputy_manager_wx" name="financial_deputy_manager_wx" lay-verify="m_wx"
                       autocomplete="off" class="layui-input" value="{$customer_info.financial_deputy_manager_wx}">
            </div>
        </div>

        <!--财务经理邮箱-->
        <div class="layui-form-item">
            <label for="financial_deputy_manager_email" class="layui-form-label">
                财务经理邮箱：
            </label>
            <div class="layui-input-block">
                <input type="text" id="financial_deputy_manager_email" name="financial_deputy_manager_email" lay-verify="m_email"
                       autocomplete="off" class="layui-input" value="{$customer_info.financial_deputy_manager_email}">
            </div>
        </div>

        <!--主管会计-->
        <div class="layui-form-item">
            <label for="accountant_leader" class="layui-form-label">
                主管会计：
            </label>
            <div class="layui-input-block">
                <input type="text" id="accountant_leader" name="accountant_leader" lay-verify="m_name"
                       autocomplete="off" class="layui-input" value="{$customer_info.accountant_leader}">
            </div>
        </div>

        <!--主管会计联系电话-->
        <div class="layui-form-item">
            <label for="accountant_leader_tel" class="layui-form-label">
                主管会计联系电话：
            </label>
            <div class="layui-input-block">
                <input type="text" id="accountant_leader_tel" name="accountant_leader_tel" lay-verify="m_phone"
                       autocomplete="off" class="layui-input" value="{$customer_info.accountant_leader_tel}">
            </div>
        </div>

        <!--主管会计联系qq-->
        <div class="layui-form-item">
            <label for="accountant_leader_qq" class="layui-form-label">
                主管会计QQ：
            </label>
            <div class="layui-input-block">
                <input type="text" id="accountant_leader_qq" name="accountant_leader_qq" lay-verify="m_qq"
                       autocomplete="off" class="layui-input" value="{$customer_info.accountant_leader_qq}">
            </div>
        </div>

        <!--主管会计联系微信-->
        <div class="layui-form-item">
            <label for="accountant_leader_wx" class="layui-form-label">
                主管会计微信：
            </label>
            <div class="layui-input-block">
                <input type="text" id="accountant_leader_wx" name="accountant_leader_wx" lay-verify="m_wx"
                       autocomplete="off" class="layui-input" value="{$customer_info.accountant_leader_wx}">
            </div>
        </div>

        <!--主管会计邮箱-->
        <div class="layui-form-item">
            <label for="accountant_leader_email" class="layui-form-label">
                主管会计邮箱：
            </label>
            <div class="layui-input-block">
                <input type="text" id="accountant_leader_email" name="accountant_leader_email" lay-verify="m_email"
                       autocomplete="off" class="layui-input" value="{$customer_info.accountant_leader_email}">
            </div>
        </div>

        <!--备注-->
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">客户备注：</label>
            <div class="layui-input-block">
                <textarea placeholder="请输入..." class="layui-textarea" name="note">{$customer_info.note}</textarea>
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-input-block">
                <input type="hidden" name="id" value="{$customer_info.id}">
                <button  class="layui-btn" lay-filter="edit" lay-submit="">
                    修改
                </button>
            </div>
        </div>

    </form>
</div>
{/block}

{block name="script"}
<script src="__JS__/jquery.raty.js"></script>
<script>
    layui.use(['form','layer'], function(){
        $ = layui.jquery;
        var form = layui.form
                ,layer = layui.layer;

        //自定义验证规则
        form.verify({
            nikename: function(value){
                if(value.length < 5){
                    return '昵称至少得5个字符啊';
                }
            }
            ,pass: [/(.+){6,12}$/, '密码必须6到12位']
            ,repass: function(value){
                if($('#L_pass').val()!=$('#L_repass').val()){
                    return '两次密码不一致';
                }
            }
            ,m_email:function (value) {
                if (value != "") {
                    //验证是否是邮箱
                    var emReg = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
                    if(!emReg.test(value)) {
                        return "请填写正确的邮箱地址!";
                    }
                }
            },
            m_qq:function (value) {
                if (value != "") {
                    //验证是否是QQ
                    var emReg = /^\d{5,11}$/;
                    if(!emReg.test(value)) {
                        return "请填写正确的QQ!";
                    }
                }
            },
            m_wx:function (value) {
                //验证是否是微信
                if (value != "") {
                    var emReg = /^[a-zA-Z0-9_-]{5,19}$/;
                    if (!emReg.test(value)) {
                        return "请填写正确的微信号!";
                    }
                }
            },
            m_phone:function (value) {
                //验证是否是手机号码 或者 座机号码
                if (value != "") {
                    var emReg = /^[\d]{7,11}$/;
                    if (!emReg.test(value)) {
                        return "请填写正确的联系电话（只能输入数字）!";
                    }
                }
            },
            m_name:function (value) {
                //验证是否是手机号码 或者 座机号码
                if (value != "") {
                    if(value.length > 10){
                        return '名字长度超出限制，最多10个字';
                    }
                }
            },
            m_input_short:function (value) {
                //验证长度是否超出限制,50个字
                if (value != "") {
                    if(value.length > 50){
                        return '内容长度超出限制，最多 50 个字';
                    }
                }
            },
            m_input_long:function (value) {
                //验证长度是否超出限制,255个字
                if (value != "") {
                    if(value.length > 255){
                        return '内容长度超出限制，最多 255 个字';
                    }
                }
            },
        });

        var province_id = {$customer_info.province_id};
        var city_id = {$customer_info.city_id};
        var district_id = {$customer_info.district_id};

        //初始化省级信息
        $.ajax({
            type: "post",
            url: "{:url('admin/region/get_region_by_parent_id', 'pid=1')}",
            dataType: "json",
            success: function(data){
                if (data.code == 1) {
                    layer.msg('获取地区清单错误，建议尝试刷新页面！',{icon:5,time:1500});
                } else {
                    var province_list = data.data;
                    $("#province").empty();
                    $("#province").append("<option value='0'>请选择省</option>");
                    for (var i=0; i < province_list.length; i++) {
                        $("#province").append("<option value="+province_list[i]['region_id']+">"+province_list[i]['region_name']+"</option>");
                    }
                    $("#province").val(province_id);
                    form.render('select', 'form-id');

                    //加载市
                    if (province_id > 0) {
                        $.ajax({
                            type: "post",
                            url: "{:url('admin/region/get_region_by_parent_id')}" + '?pid='+province_id,
                            dataType: "json",
                            success: function(data){
                                if (data.code == 1) {
                                    layer.msg(data.msg,{icon:5,time:1500});
                                } else {
                                    var region_list = data.data;
                                    $("#city").empty();
                                    $("#city").append("<option value='0'>指定市</option>");
                                    for (var i=0; i < region_list.length; i++) {
                                        $("#city").append("<option value="+region_list[i]['region_id']+">"+region_list[i]['region_name']+"</option>");
                                    }
                                    $("#city").val(city_id);
                                    form.render('select', 'form-id');
                                }
                            }, error: function(){
                                layer.msg("请求地区清单出错",{icon:5,time:1500});
                            }
                        });
                    }

                    //加载县区
                    if (city_id > 0) {
                        $.ajax({
                            type: "post",
                            url: "{:url('admin/region/get_region_by_parent_id')}" + '?pid=' + city_id,
                            dataType: "json",
                            success: function (data) {
                                if (data.code == 1) {
                                    layer.msg(data.msg, {icon: 5, time: 1500});
                                } else {
                                    var region_list = data.data;
                                    $("#district").empty();
                                    $("#district").append("<option value='0'>指定区/县</option>");
                                    for (var i = 0; i < region_list.length; i++) {
                                        $("#district").append("<option value=" + region_list[i]['region_id'] + ">" + region_list[i]['region_name'] + "</option>");
                                    }
                                    $("#district").val(district_id);
                                    form.render('select', 'form-id');
                                }
                            }, error: function () {
                                layer.msg("请求地区清单出错", {icon: 5, time: 1500});
                            }
                        });
                    }
                }
            }, error: function(){
                layer.msg("请求地区清单出错",{icon:5,time:1500});
            }
        });

        //监听提交
        form.on('submit(edit)', function(data){
            $("#from_id").ajaxSubmit({
                beforeSubmit:function () {
                    //表单提交前
                    //验证编号规则
                    /*var prefix = $("#customer-number-prefix").val();
                    var msg = '';
                    if (prefix == '' || prefix == undefined) {
                        msg = "客户编号的前缀必须填写!";
                        layer.msg(msg,{icon:5,time:1500});
                    }

                    var emReg = /^[a-zA-Z]{3}$/;
                    if (!emReg.test(prefix)) {
                        msg = "请填写正确的客户编号前缀（只能输入3位字母）!";
                        layer.msg(msg, {icon:5,time:1500});
                    }
                    prefix = prefix.toUpperCase();
                    $("#customer-number-prefix").val(prefix);

                    var number = $("#customer-number-number").val();
                    if (number == '' || number == undefined) {
                        msg = "客户编号的序号必须填写!";
                        layer.msg(msg,{icon:5,time:1500});
                    }

                    emReg = /^\d{1,5}$/;
                    if (!emReg.test(number)) {
                        msg = "请填写正确的客户编号序号（只能输入最多5位数字）!";
                        layer.msg(msg, {icon:5,time:1500});
                    }

                    if (msg != '') {
                        return false;
                    } else {
                        return true;
                    }*/
                },
                success:function (data) {
                    //console.log(JSON.stringify(data));
                    if (data.code == 1) {
                        layer.msg(data.msg,{icon:5,time:1500});
                    } else {
                        layer.alert("修改成功", {icon: 6},function () {
                            // 获得frame索引
                            var index = parent.layer.getFrameIndex(window.name);
                            //关闭当前frame
                            parent.layer.close(index);
                            //刷新父层页面
                            parent.location.replace(parent.location.href);
                        });
                    }
                }
            });
            return false;
        });

        //监听省市区下拉框选择
        form.on('select(region)', function(data){
            var pid = data.value;   //当前选中的地区id：region_id
            var type = $(data.elem).attr('id');
            if (pid > 0 && type != 'district') {

                var id = '';
                var name = '';
                if (type == 'province') {
                    id = 'city';
                    name = '市';
                    //清空区域数据，保证数据被重置
                    $('#district').empty();
                    $("#district").append("<option value='0'>请选择县/区"+"</option>");
                    form.render('select');
                } else if (type == 'city') {
                    id = 'district';
                    name = '县/区';
                } else {
                    layer.msg('省市区信息异常！',{icon:5,time:1500});
                    return;
                }

                $.ajax({
                    type: "post",
                    url: "{:url('admin/region/get_region_by_parent_id')}" + '?pid='+pid,
                    dataType: "json",
                    success: function(data){
                        if (data.code == 1) {
                            layer.msg(data.msg,{icon:5,time:1500});
                        } else {
                            var region_list = data.data;
                            $("#"+id).empty();
                            $("#"+id).append("<option value='0'>请选择"+name+"</option>");
                            for (var i=0; i < region_list.length; i++) {
                                $("#"+id).append("<option value="+region_list[i]['region_id']+">"+region_list[i]['region_name']+"</option>");
                            }
                            form.render('select');
                        }
                    }, error: function(){
                        layer.msg("请求地区清单出错",{icon:5,time:1500});
                    }
                });
            }
        });

        //帮助信息
        $('#star-level-help').bind('click', function () {
            layer.open({
                type:1,
                btn:'',//按钮内容
                //area: ['400px', '280px'],
                maxmin:true,
                anim:1,//弹框显示特效
                title: '星级评定规则',
                content: "{$star_level_config_doc}" //这里content是一个普通的String
            });
        });

        //点击 “纳税人识别号时，会自动根据输入的 单位名称进行查询”
        $('#select-taxpayer_identity_numbe').bind('click', function () {
            //单位名称
            var company_name = $('#company_name').val();

            window.open('http://www.gsxt.gov.cn/index.html');
        });

        var star_level_config = {$star_level_config};

        //监听业务额的录入
        $('#revenue').on('keydown', function() {
            setTimeout(function() {
                var revenue = $('#revenue').val();
                revenue = parseInt(revenue);
                var star_counts = 0;
                if (star_level_config != '' && star_level_config != 'undefine') {
                    for (var i = 0; i < star_level_config.length; i++) {
                        if (star_level_config[i]['desc'] != '') {
                            //默认值,不用处理
                            if (revenue == 0) {
                                star_counts = star_level_config[i]['star_level'];
                                break;
                            }
                            continue;
                        }

                        //需要通过业务额具体的区间进行判断：如果输入的数字小于当前最小值，则使用默认1星即可，因为规则数字是从小到大
                        if (star_level_config[i]['revenue_min'] > revenue) {
                            break;
                        }
                        if (star_level_config[i]['revenue_max'] == 0 || revenue <= star_level_config[i]['revenue_max']) {
                            star_counts = star_level_config[i]['star_level'];
                            break;
                        }
                    }

                    //改变星星数量
                    //$('input[name="star_level"]').val(star_counts);
                    $("#star-level-id").raty({
                        score:star_counts,
                        starOn: '__IMAGES__/star_level/star-on.png',//鼠标放上去时显示的图标的位置
                        starOff: '__IMAGES__/star_level/star-off.png',//鼠标离开后显示的图标的位置
                        size: 50,
                        scoreName: 'star_level',
                        number:{$star_level_config}.length,
                    });
                }
            }, 1500);
        });
    });

    /*格式化数字，不足指定为数时，前面补0*/
    function PrefixInteger(num, length) {
        return ( "0000000000000000" + num ).substr( -length );
    }

    /*检查客户编号的前缀*/
    $('.check-customer-number').bind('blur', function () {
        var prefix = $("#customer-number-prefix").val();
        var msg = '';
        if (prefix == '' || prefix == undefined) {
            msg = "客户编号的前缀必须填写!";
            layer.msg(msg,{icon:5,time:1500});
        }

        var emReg = /^[a-zA-Z]{3}$/;
        if (!emReg.test(prefix)) {
            msg = "请填写正确的客户编号前缀（只能输入3位字母）!";
            layer.msg(msg, {icon:5,time:1500});
        }
        prefix = prefix.toUpperCase();
        $("#customer-number-prefix").val(prefix);

        var number = $("#customer-number-number").val();
        if (number == '' || number == undefined) {
            msg = "客户编号的序号必须填写!";
            layer.msg(msg,{icon:5,time:1500});
        }

        emReg = /^\d{1,5}$/;
        if (!emReg.test(number)) {
            msg = "请填写正确的客户编号序号（只能输入最多5位数字）!";
            layer.msg(msg, {icon:5,time:1500});
        }
        //不能从0开始
        if (number == 0) {
            number = 1;
        }
        number = PrefixInteger(number, 5);
        $("#customer-number-number").val(number);

        if (msg != '') {
            $("#show-customer-number").html(msg);
        } else {
            $("#show-customer-number").html(prefix+number);
        }
    });




    $("#star-level-id").raty({
        score: function () {
            //return $(this).attr("data-num");
            return {$customer_info.star_level};
        },//需要显示的星星个数
        number:{$star_level_config}.length,
        starOn: '__IMAGES__/star_level/star-on.png',//鼠标放上去时显示的图标的位置
        starOff: '__IMAGES__/star_level/star-off.png',//鼠标离开后显示的图标的位置
        //starHalf: '__IMAGES__/star_level/star-half-big.png',//需要显示的半星的标图的位置
        readOnly: false,//所显示的星星是否只读，默认非只读
        halfShow: false,//半个星星是否可以显示，默认可以
        size: 60,//div显示的长度，太短了星星会换行
        scoreName: 'star_level',//隐藏input的name
    });
</script>
{/block}